#!/usr/bin/python

import cgi 
import cgitb
import fortune
cgitb.enable()

print "Content-Type: text/html\n"

print "<html>"
print "<body>"
print "<head><title>Fortune</title></head>"
form = cgi.FieldStorage() 

if form.has_key("m"):
    #m = form["m"].value //alternative
    m = form.getvalue("m")
    print fortune.getQuote(m)

else:
    m=""
    print fortune.getRandomQuote()

print "<form action='fortune.cgi'>"
print "In Zitat enthalten: <br>\n"
print "<input name='m' type='text' size='30' maxlength='30' value=",m,">"
print "<input type='Submit' value='Ok'>"


print "</form>"
print "</body>"
print "</html>"
